/*
 * RunButtonListener
 * 
 * Version information:1.0
 *
 * Date: 19/11/2012
 */
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JTextArea;
import javax.swing.JTextField;

/**
 * @author dv11rlm
 */
public class RunButtonListener implements ActionListener {
    private JTextField runInput;
    private JTextArea textArea;

    /**
     * initialize variables and make sure variables are not null.
     * 
     * @param myInputField
     * @param myText
     */
    public RunButtonListener(JTextField myInputField, JTextArea myText) {
	runInput = myInputField;
	textArea = myText;

	if (runInput == null || textArea == null) {
	    throw new NullPointerException("JTextField and/or textArea is null");
	}

    }

    /**
     * Start new work thread that test class if a className has been
     * given by the user.
     */
    @Override
    public void actionPerformed(ActionEvent arg0) {
	if (runInput.getText().length() > 0) {
	    new Thread(new MyUnitTester(runInput.getText(), textArea)).start();
	}
    }

}
